package com.zut.service.Impl;

import com.zut.dao.UserDao;
import com.zut.pojo.User;
import com.zut.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    // 登录查询手机号和密码
    @Override
    public User getUserByPhoneAndPassword(User user) {
        return userDao.selectByNameAndPassword(user.getPhone(),user.getPassword());
    }

    // 注册功能的实现
    @Override
    public int register(User user) {
        return userDao.addUser(user.getPhone(),user.getUsername(),user.getPassword());
    }

    // 检验手机号是否已注册过
    @Override
    public User telTest(String phone) {
        return userDao.selectUserByPhone(phone);
    }

    // 用户认证
    @Override
    public boolean addAuthentication(User user) {
        return userDao.addAuthentication(user)==1;
    }

    // 根据id查询用户
    @Override
    public User selectUserById(Integer id) {
        return userDao.selectUserById(id);
    }
}
